jDev.win = {
    
  _id: 'jDev',
  _height: 200,
    
  _element: null,
  _template: '<div id="jdHeader"><div id="jdTitlebar"><div id="jdTitle">jDev - jProton Developer Tools</div><div id="jdTitleControls"> <a id="jdCtrClear" href="#">clear</a></div><div id="jdTitleButtons"> <a id="jdBtnMin" href="#">min</a> <a id="jdBtnMax" href="#">max</a> <a id="jdBtnClose" href="#">close</a></div><div class="jdClear"></div></div><div id="jdTabs"><ul><li><a href="#" class="jdSelTab">Console</a></li><li><a href="#">Todo&#39;s</a></li><li><a href="#">Tests</a></li><li><a href="#">Build</a></li><li><a href="#">Docs</a></li><li><a href="#">Bug-report</a></li><li><a href="#">Trac</a></li><li><a href="#">Svn</a></li><li><a href="#">Support</a></li></ul></div></div><div id="jdConsole" class="jdTab"><div id="jdConsole_Out"></div><div id="jdConsole_CmdWrap"><div id="jdConsole_CmdIcon">&gt;&gt;&gt;</div> <input id="jdConsole_Cmd" name="jdConsole_Cmd" type="text"/></div></div>',
  
  _maximized: false,
  
  init: function() {
    var win = jDev.win;
    var d = document;
    
    win.create();
    
    jDev.event.add(
        d, 
        jDev.isIE || jDev.isSafari ? 'keydown' : 'keypress', 
        jDev.win.onKeyDown
      );

    jDev.event.add(window, 'resize', jDev.win.draw);
    
    d.getElementById('jdBtnClose').href = 'javascript:jDev.win.hide();';
    d.getElementById('jdBtnMax').href = 'javascript:jDev.win.maximize();';
    d.getElementById('jdBtnMin').href = 'javascript:jDev.win.minimize();';
    
    d.getElementById('jdCtrClear').href = 'javascript:jDev.console.clear();';
    
    jDev.console.init();
    
    setTimeout(win.show, 10);
  },
  
  create: function() {
    var win = jDev.win;
    var el = win._element = document.createElement('div');
    el.id = win._id;
    el.innerHTML = win._template;
    
    document.body.appendChild(el);
  },
  
  draw: function() {
    var win = jDev.win;
    var console = jDev.console;
    var style = win._element.style;
    
    style.width = document.body.clientWidth + 'px';
    
    var headerHeight = document.getElementById('jdHeader').offsetHeight;
    var cmdHeight = document.getElementById('jdConsole_CmdWrap').offsetHeight;
    var height = win._maximized ? 
        document.body.clientHeight : 
        win._height;
    
    style.height = height + 'px';
    console._outElement.style.height = height -headerHeight -cmdHeight + 'px';
  },
  
  isVisible: function() {
    return jDev.getCSS(jDev.win._element, 'display') != 'none';
  },
  
  show: function(){
    jDev.win._element.style.display = 'block';
    jDev.console._cmdElement.focus();
    setTimeout(jDev.win.draw, 10);
  },
  
  hide: function(){
    jDev.win._element.style.display = 'none';
  },
  
  toggle: function(){
    var win = jDev.win;
    
    if(win.isVisible()) {
      win.hide();
    } else {
      win.show();
    }
  },
  
  maximize: function() {
    var win = jDev.win;
    if (!win._maximized) {
      win._maximized = true;
      win.draw();
    }
  },
  
  minimize: function() {
    var win = jDev.win;
    if (win._maximized) {
      win._maximized = false;
      win.draw();
    }
  },
  
  onKeyDown: function(event) {
    if (event.keyCode == 123 && event.shiftKey) {
      jDev.win.toggle();
    } else {
      return;
    }
    
    jDev.event.stop(event);
  }
  
};

jDev.onReady(jDev.win.init);